package cn.uc.bs.dip;

import cn.uc.app.Values;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Message;

public abstract class ImageProcessor implements Runnable{
    protected Bitmap image;
    protected Handler mHandler = null;
    private volatile boolean isRunning = true;    
    public ImageProcessor(Bitmap aBitmap){
        image = aBitmap;
    }
    
    public void setHandler(Handler aHandler){
        mHandler = aHandler;
    }
    
    public void run(){
        if(isRunning){
            Bitmap sBitmap = process();
            if(mHandler != null){
                mHandler.sendMessage(Message.obtain(mHandler, Values.MSG_IMAGE_PROCESSED, sBitmap));
            }
        }
    }
    
    protected abstract Bitmap process();
}
